package movee.utils.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public final class ListUtils {

    private ListUtils() { }

    @SafeVarargs
    public static <T> List<T> newArrayListOfUnion(Collection<T>... origins) {
        ArrayList<T> result = new ArrayList<>();
        for (Collection<T> origin : origins) {
            result.addAll(origin);
        }
        return result;
    }

    public static <T> List<T> newArrayListOfIntersection(Collection<T> src, Collection<T> dst) {
        ArrayList<T> result = new ArrayList<>(src);
        result.retainAll(dst);
        return result;
    }

    public static <T> List<T> newArrayListOfDifference(Collection<T> src, Collection<T> dst) {
        List<T> result = new ArrayList<>(src);
        result.removeAll(dst);
        return result;
    }
}
